import { MenuConfig } from '../MenuManager';

export interface MenuTheme {
    backgroundColor: string;
    borderColor: string;
    textColor: string;
    highlightColor: string;
}

export abstract class BaseMenu {
    protected config: MenuConfig;
    protected theme: MenuTheme;

    constructor(config: MenuConfig) {
        this.config = config;
        this.theme = this.initializeTheme();
    }

    protected initializeTheme(): MenuTheme {
        return {
            backgroundColor: '#1a1a1a',
            borderColor: 'rgb(132, 227, 255)',
            textColor: '#ffffff',
            highlightColor: '#00ff00'
        };
    }

    public abstract render(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement): void;
    public abstract handleClick(x: number, y: number, canvas: HTMLCanvasElement): string | null;
    public abstract update(deltaTime: number): void;

    protected getConfig(): MenuConfig {
        return this.config;
    }

    protected saveConfig(): void {
        try {
            localStorage.setItem('gameConfig', JSON.stringify(this.config));
        } catch (e) {
            console.error('配置保存失败:', e);
        }
    }
}